/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.core.http.request;

import com.google.common.collect.Maps;
import info.peigen.hotpot.component.gateway.core.http.enums.HttpProtocol;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import org.noear.solon.core.handle.MethodType;

import java.io.Serializable;
import java.util.Map;

import static org.noear.solon.core.handle.MethodType.POST;

/**
 * <b>(HttpRequest)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2019-05-29
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class HttpRequest implements Serializable {
    static final long serialVersionUID = 5503237702885939013L;

    /** 报文 */
    String requestMessage;

    /** 报文 map格式 */
    Map<String, String> requestMessageMap;

    /** 签名串 */
    String requestSignature;

    /** 请求地址 */
    String requestUrl;

    /** 服务协议 */
    @Builder.Default
    HttpProtocol protocol = HttpProtocol.HTTP_JSON;

    /** 扩展参数 */
    @Builder.Default
    Map<String, Object> extend = Maps.newHashMap();

    /** 请求方式 */
    @Builder.Default
    MethodType methodType = POST;

    /** 连接超时时间 */
    @Builder.Default
    long connectTimeout = 3000;

    /** 读超时时间 */
    @Builder.Default
    long readTimeout = 4000;

    /**
     * @param requestUrl 请求url
     */
    public HttpRequest(String requestUrl) {
        super();
        this.requestUrl = requestUrl;
    }

}